﻿Imports capaNegocios

Public Class secCurso_modificar
    Inherits System.Web.UI.Page

    Dim idCurso As String
    Dim estadoCurso As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            Dim objCurso = New clsCurso
            Dim curso = New DataTable

            objCurso.id = Request.QueryString("codCurso")
            curso = objCurso.BuscarPorCodigo()

            Me.idCurso = curso.Rows(0)("CUR_ID")
            Me.txtCursoModificar.Text = curso.Rows(0)("CUR_Nombre")
            Me.ddlHoraTeoricaModificar.SelectedValue = curso.Rows(0)("CUR_HoraTeorica")
            Me.ddlHoraPracticaModificar.SelectedValue = curso.Rows(0)("CUR_HoraPractica")
            Me.txtDescripcionModificar.Text = curso.Rows(0)("CUR_Descripcion")
            Me.estadoCurso = curso.Rows(0)("CUR_Estado")
        End If
    End Sub

    Protected Sub btnModificarCurso_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnModificarCurso.Click
        Dim objCurso = New clsCurso

        objCurso.id = Request.QueryString("codCurso")
        objCurso.nombre = Me.txtCursoModificar.Text
        objCurso.horasTeoricas = Me.ddlHoraTeoricaModificar.SelectedValue
        objCurso.horasPracticas = Me.ddlHoraPracticaModificar.SelectedValue
        objCurso.descripcion = Me.txtDescripcionModificar.Text
        objCurso.estado = Me.ddlEstadoModificar.SelectedValue

        If objCurso.Actualizar() = True Then
            MsgBox("Curso modificado con éxito.")
            Response.Redirect("secCurso.aspx")
        Else
            MsgBox("Error al modificar curso.")
        End If
    End Sub
End Class